﻿# CMakeList.txt: CMakeProject-test 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.10)

# 如果支持，请为 MSVC 编译器启用热重载。
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("CMakeProject-test" VERSION 1.0 LANGUAGES C CXX)

# 设置指定的C++编译器版本是必须的，如果不设置，或者为OFF，则指定版本不可用时，会使用上一版本。
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 指定为C++20 版本
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_COMPILER_VERSION "20")

# lib目录
set(MY_LIB_DIR ${CMAKE_SOURCE_DIR}/lib)

find_package(OpenSSL REQUIRED)
find_package(PThreads4W REQUIRED)
find_package(ZLIB REQUIRED)

# 将源代码添加到此项目的可执行文件。
add_executable (${PROJECT_NAME} "CMakeProject-test.cpp" "CMakeProject-test.h")

# 指定 C++20 标准
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property (TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
endif()

# 拷贝目录
file (COPY conf/ DESTINATION conf/)
file (COPY cert/ DESTINATION cert/)

# 扫描子目录 cmake 配置文件
add_subdirectory (src)

# 引用头文件目录
# include_directories (${CMAKE_SOURCE_DIR}/include)
# 引用库文件目录
# link_directories (${CMAKE_SOURCE_DIR}/lib)

# find_library (YAML_LIB yaml-cpp ${CMAKE_SOURCE_DIR}/lib)

# 引用头文件目录
target_include_directories (${PROJECT_NAME} PRIVATE 
							${CMAKE_SOURCE_DIR}/include
							${OPENSSL_INCLUDE_DIR}
)

# 添加lib引用
target_link_libraries (${PROJECT_NAME} PRIVATE ${MY_LIB_DIR}/yaml-cppd.lib)
if (WIN32)
	target_link_libraries (${PROJECT_NAME} PRIVATE wsock32 ws2_32)
endif ()
target_link_libraries (${PROJECT_NAME} PRIVATE OpenSSL::SSL)
target_link_libraries (${PROJECT_NAME} PRIVATE OpenSSL::Crypto)
target_link_libraries (${PROJECT_NAME} PRIVATE PThreads4W::PThreads4W)
target_link_libraries (${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
target_link_libraries (${PROJECT_NAME} PRIVATE NetServer)
target_link_libraries (${PROJECT_NAME} PRIVATE HTTPSService)
target_link_libraries (${PROJECT_NAME} PRIVATE Utils)
target_link_libraries (${PROJECT_NAME} PRIVATE HttpClient)
target_link_libraries (${PROJECT_NAME} PRIVATE CodeConvert)
# target_link_libraries (${PROJECT_NAME} PRIVATE Test)
# target_link_libraries (${PROJECT_NAME} PRIVATE DemoService)
# target_link_libraries (${PROJECT_NAME} PRIVATE HttpsNewService)

# TODO: 如有需要，请添加测试并安装目标。